//
//  MyPetViewController.m
//  chongwu
//
//  Created by 隼目 on 2021/9/17.
//

#import "MyPetViewController.h"
#import "MyPetTableViewCell.h"
#import "PetInformationViewController.h"
@interface MyPetViewController ()<UITableViewDelegate,UITableViewDataSource,myPetDelegate>
@property(nonatomic,strong)BaseTableView *tableView;
@property(nonatomic,strong)NSMutableArray *selcetCellArr;

@property(nonatomic,strong)NSMutableArray *tableArr;

@end

@implementation MyPetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"我的宠物";
    self.tableArr=[NSMutableArray arrayWithCapacity:0];
    
    self.selcetCellArr=[NSMutableArray arrayWithCapacity:0];
   
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"xinzeng"] style:UIBarButtonItemStylePlain target:self action:@selector(pushTAddress)];
    
    self.tableView=[BaseTableView new];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(0);
    }];
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.backgroundColor=rgba(245, 246, 246, 1);
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
}
-(void)pushTAddress{
    PetInformationViewController *vc=[[PetInformationViewController alloc] init];
    vc.isHidenDog=YES;
    [ZQTools pushRootViewController:self  andNextController:vc];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    MyPetTableViewCell *cell=[[MyPetTableViewCell alloc] init];
    cell.delegate=self;
    cell.typeIndex=self.typeIndex;
    if (indexPath.row<4) {
        cell.tag=indexPath.row;
        cell.selected=NO;
        for (NSString *typeStr in self.selcetCellArr) {
            if (typeStr.integerValue==indexPath.row) {
                cell.selected=YES;
            }
        }
        [cell creatView];
    }else{
        [cell creatBtnView];
    }
    
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row<4) {
        return 306*_mainHeight;
    }
    return 167*_mainHeight;
}
-(void)selectCell:(NSInteger)index{
    BOOL isHave=NO;
    for (NSString *typeStr in self.selcetCellArr) {
        if (typeStr.integerValue==index) {
            isHave=YES;
            break;
        }
    }
    if (isHave) {
        [self.selcetCellArr removeObject:[NSString stringWithFormat:@"%ld",index]];
    }else{
        [self.selcetCellArr addObject:[NSString stringWithFormat:@"%ld",index]];
    }
    [self.tableView reloadData];
}
-(void)gateData{
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
